//
//  PlistIntegrateViewController.m
//  SDKSample
//
//  Created by 小肥羊 on 15/10/20.
//  Copyright © 2015年 Zhu‘s Game House. All rights reserved.
//

#import "PlistIntegrateViewController.h"
#import "XFYPlistTool.h"

@interface PlistIntegrateViewController ()

@end

@implementation PlistIntegrateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.plistNameText.delegate = self;
}

- (IBAction)addClick:(id)sender {
    NSLog(@"添加%@",self.plistNameText.text);
    [XFYPlistTool createArrayPlistWithName:self.plistNameText.text];
}
- (IBAction)messageInfo:(id)sender {
    NSMutableArray *messageList = [XFYPlistTool PlistWithName:self.plistNameText.text];
    for (NSDictionary *data in messageList) {
        NSLog(@"%@",data);
    }
}

- (IBAction)addMessage:(id)sender {
    NSMutableDictionary *message = [[NSMutableDictionary alloc] init];
    [message setObject:@"标题3" forKey:@"title"];
    [message setObject:@"内容3" forKey:@"value"];
    NSMutableArray *messageList = [XFYPlistTool addDictInArrayPlist:self.plistNameText.text Dict:message];
    for (NSDictionary *data in messageList) {
        NSLog(@"%@",data);
    }
}
- (IBAction)deletMessage:(id)sender {
    NSMutableArray *messageList = [XFYPlistTool deletDictInArrayPlist:self.plistNameText.text AtIndex:0];
    for (NSDictionary *data in messageList) {
        NSLog(@"%@",data);
    }
}

- (IBAction)modifyMessage:(id)sender {
    NSMutableDictionary *message = [[NSMutableDictionary alloc] init];
    [message setObject:@"新新新的1" forKey:@"title"];
    [message setObject:@"新新新新新新1" forKey:@"value"];
    NSMutableArray *messageList = [XFYPlistTool modifyDictInArrayPlist:self.plistNameText.text AtIndex:0 Dict:message];
    for (NSDictionary *data in messageList) {
        NSLog(@"%@",data);
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
